package com.yrd.fssync.core;

import java.io.File;

public class SyncRequest {
	public static final int DISPOSE_OVERWRITE=0;
	public static final int DISPOSE_DELETE=1;
	public static final int FILETYPE_FILE=0;
	public static final int FILETYPE_DIR=1;
	
//	public static final int FEATURE_COPY_DIR = 1<<0;
	
	File localFile;
	String remote;
	int fileType;
	int dispose;
	int feature;
	long timestamp;

	public SyncRequest() {
		this.timestamp = System.currentTimeMillis();
	}

	public SyncRequest(File localFile,String remote,int fileType,int dispose) {
		this.localFile = localFile;
		this.remote = remote;
		this.fileType = fileType;
		this.dispose = dispose;
		this.timestamp = System.currentTimeMillis();
	}


	public String getRemote() {
		return remote;
	}

	public void setRemote(String remote) {
		this.remote = remote;
	}


	public File getLocalFile() {
		return localFile;
	}

	public void setLocalFile(File localFile) {
		this.localFile = localFile;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

	public int getDispose() {
		return dispose;
	}

	public void setDispose(int dispose) {
		this.dispose = dispose;
	}
	
	public int getFileType() {
		return fileType;
	}
	public void setFileType(int fileType) {
		this.fileType = fileType;
	}
	public int getFeature() {
		return feature;
	}
	public void setFeature(int feature) {
		this.feature = feature;
	}
	public void addFeature(int featrueItem) {
		this.feature |= feature;
	}
	public boolean hasFeatrue(int featrueItem){
		return (this.feature & featrueItem) !=0 ;
	}

	public boolean isOverwrite(){
		return dispose == DISPOSE_OVERWRITE;
	}
	public boolean isDelete(){
		return dispose == DISPOSE_DELETE;
	}
	public boolean isFile(){
		return fileType == FILETYPE_FILE;
	}
	public boolean isDir(){
		return fileType == FILETYPE_DIR;
	}

	@Override
	public String toString() {
		return "SyncRequest [localFile=" + localFile + ", remote=" + remote
				+ ", fileType=" + fileType + ", dispose=" + dispose
				+ ", feature=" + feature + ", timestamp=" + timestamp + "]";
	}

	public String titleString(){
		StringBuffer sb = new StringBuffer();
		if(dispose == DISPOSE_OVERWRITE){
			sb.append("新增/修改");
		}else if(dispose==DISPOSE_DELETE){
			sb.append("删除");
		}
		sb.append(" ").append(localFile.getName());
		return sb.toString();
	}
	
}
